#include<bits/stdc++.h>
using namespace std;
#define int long long

int a[200005];

signed main() {
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
	}

	unordered_map<int, int> cnt;
	cnt[0] = 1;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += cnt[a[i] % k];
		cnt[a[i] % k]++;
	}
	cout << ans;
	return 0;
}

